from django.urls import re_path
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token
from .view import statstics, users, articles
from .view.articles import ArticleAPIView, ArticleImageAPIView
from .view.order import OrderView
from .view.systems import PermissionsAPIView, GroupsAPIView, AdminsAPIView

urlpatterns = [
    re_path('^mg_admin/login/$',obtain_jwt_token),
    re_path('^statistics/total_count/$',statstics.UserToalAPIView.as_view()),
    re_path('^statistics/day_increment/$',statstics.UserDayCountView.as_view()),
    re_path('^statistics/day_active/$',statstics.UserActiveCountView.as_view()),
    re_path('^statistics/time_order_count/$',statstics.TimeOrderCountView.as_view()),
    re_path('^mg_admin/users/$',users.UserAPIView.as_view()),
    re_path('^mg_admin/categories/$',articles.CategoryAPIView.as_view()),
]

# 视图集
router = routers.SimpleRouter()

router.register('articles',ArticleAPIView,'article')
router.register('article_imgs',ArticleImageAPIView,'article_img')
router.register('orders',OrderView,'order')
router.register('permissions',PermissionsAPIView,'permission')
router.register('groups',GroupsAPIView,'group')
router.register('admins',AdminsAPIView,'admin')

urlpatterns += router.urls

